Skip to content

Conversation

djabarovgeorge
Copy link
Contributor

What changed? Why was the change needed?

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

…ions

- Introduced resourceConditions and subscriberConditions in the topic subscriptions feature to allow conditional notifications based on JSONLogic rules.
- Added a new EvaluateSubscriptionConditions use case to evaluate these conditions.
- Updated relevant DTOs and repositories to support the new fields and logic.
- Included a condition hash for efficient subscription management.
- Added json-logic-js as a dependency for condition evaluation.
@linear
Copy link

linear bot commented Oct 20, 2025

@netlify
Copy link

netlify bot commented Oct 20, 2025

Deploy Preview for dashboard-v2-novu-staging failed. Why did it fail? →

Name Link
🔨 Latest commit d217453
🔍 Latest deploy log https://app.netlify.com/projects/dashboard-v2-novu-staging/deploys/68fa382dff8d3300082a67f0

@github-actions github-actions bot changed the title feat(api): add resource and subscriber conditions for topic subscript… feat(api): add resource and subscriber conditions for topic subscript… fixes NV-6810 Oct 20, 2025
@djabarovgeorge djabarovgeorge changed the title feat(api): add resource and subscriber conditions for topic subscript… fixes NV-6810 feat(api-service): implement multi subscription with condition to topic Oct 20, 2025
@github-actions github-actions bot changed the title feat(api-service): implement multi subscription with condition to topic feat(api-service): implement multi subscription with condition to topic fixes NV-6810 Oct 20, 2025
…te repository methods

- Renamed 'condition' to 'conditions' across various DTOs and use cases for consistency.
- Updated the TopicSubscribersRepository to implement a new method for bulk subscription creation, returning detailed results for created, updated, and failed subscriptions.
- Removed the EvaluateSubscriptionConditions use case as its functionality has been integrated into the TriggerMulticast use case.
- Adjusted related logic to accommodate the new structure for conditions.
@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Oct 20, 2025

1 Job Failed:

Check pull request / Find LaunchDarkly feature flags in diff failed on "Find flags"
  > Run launchdarkly/find-code-references-in-pull-request@v2
  with:
    project-key: default
    environment-key: production
    access-token: ***
    repo-token: ***
    placeholder-comment: false
    include-archived-flags: true
    max-flags: 5
    base-uri: https://app.launchdarkly.com
    check-extinctions: true
    create-flag-links: true
  env:
    NX_CLOUD_ACCESS_TOKEN: ***
    GITHUB_REPO_NAME: novuhq/novu

2025/10/20 17:43:04 unexpected status code: 503. unable to parse response: EOF
Error: unexpected status code: 503. unable to parse response: EOF

Summary: 3 successful workflows, 1 failed workflow

Last updated: 2025-10-20 17:58:34 UTC

if (conditionHash !== undefined) {
existingSubscriptionsQuery.conditionHash = conditionHash;
} else {
existingSubscriptionsQuery.$or = [{ conditionHash: { $exists: false } }, { conditionHash: null }];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate if we ca use rooted $or

const passingSubscriptions = subscriptionsBatch.filter((subscription) => {
return this.evaluateConditions(
subscription.conditions as Record<string, unknown>,
{ payload: command.payload } as Record<string, unknown>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we will need to add workflow entity variable as well

Comment on lines +167 to +180
const cursor = this._model
.find(
{
_organizationId: this.convertStringToObjectId(_organizationId),
_environmentId: this.convertStringToObjectId(_environmentId),
_topicId: { $in: mappedTopicIds },
externalSubscriberId: { $nin: excludeSubscribers },
},
},
{
$group: {
_id: '$externalSubscriberId',
topics: { $push: '$_topicId' },
},
},
];
{
externalSubscriberId: 1,
conditions: 1,
}
)
.cursor({ batchSize });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the missing grouping by subscriber id could couse more copute, because we could fetch duplicated subscribers, however we still need them because 1 subscriber could pass the condition while the other will not.

@djabarovgeorge djabarovgeorge marked this pull request as ready for review October 20, 2025 14:21
- Enhanced the topic subscriptions feature by introducing a new workflows field in the relevant DTOs and use cases.
- Updated the TopicsController to handle workflows in subscription requests.
- Modified the CreateTopicSubscriptions use case to process and store workflows associated with subscriptions.
- Added validation and transformation logic for workflows in the DTOs.
- Updated end-to-end tests to verify the correct handling of workflows in subscription creation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant